package com.yonyou.sto.modules.ims.controller;

import com.yonyou.sto.common.api.CommonResult;
import com.yonyou.sto.modules.ims.dto.CallbackInvoiceParam;
import com.yonyou.sto.modules.ims.dto.OpenReturn;
import com.yonyou.sto.modules.ims.service.OpenBillService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.security.Principal;
import java.util.List;
import java.util.Map;

/**
 * @author ：Aegon Targaryen
 * @version ：1.0-SNAPSHOT
 * @date ：Created in 2020/9/25 14:09
 * @description ：开票管理
 * @modifiedBy ：
 */
@RestController
@Api(tags = "OpenBillController", description = "开票管理")
@RequestMapping(value = "/server/oms")
public class OpenBillController {


    @Resource
    private OpenBillService openBillService;

    @ApiOperation("调用申请开票接口")
    @RequestMapping(value = "/callInvoiceApply", method = RequestMethod.POST)
    public CommonResult callInvoiceApply(Principal principal, @RequestParam List<String> billIds,
                                         @RequestParam(required = false) List<String> billItemIds,
                                         @RequestParam Integer billType,
                                         @RequestParam() Integer contain) {
        return openBillService.callInvoiceApply(principal, billIds, billItemIds, billType, contain);
    }

    @ApiOperation("调用退回开票接口")
    @RequestMapping(value = "/callInvoiceReturnApply")
    public CommonResult callInvoiceReturnApply(Principal principal, @RequestParam String id) {
        //return null;
        return openBillService.callInvoiceReturnApply(principal, id);
    }

    @ApiOperation("开蓝票回调接口")
    @RequestMapping(value = "/callbackInvoiceApply", method = RequestMethod.POST)
    public Map<String, String> callbackInvoiceApply(@RequestBody CallbackInvoiceParam callbackInvoiceParam) {
        return openBillService.callbackInvoiceApply(callbackInvoiceParam);
    }

    @ApiOperation("开票状态查询服务")
    @RequestMapping(value = "/queryInvoiceApply", method = RequestMethod.GET)
    public CommonResult queryInvoiceApply(@RequestParam String fpqqlsh) {
        return openBillService.queryInvoiceApply(fpqqlsh);
    }

//    @ApiOperation("发票红冲")
//    @PostMapping("/openRedBill")
//    public CommonResult openRedBill(@RequestParam List<String> billIds) {
//        return openBillService.openRedBill(billIds);
//    }

    @ApiOperation("开红票回调接口")
    @RequestMapping(value = "/openRedBillCallback", method = RequestMethod.POST)
    public Map<String, String> openRedBillCallback(@RequestBody CallbackInvoiceParam callbackInvoiceParam) {
        return openBillService.openRedBillCallback(callbackInvoiceParam);
    }
    @ApiOperation("退回接口")
    @RequestMapping(value = "/openReturn", method = RequestMethod.POST)
    public Map<String, String> openReturn(@RequestBody OpenReturn openReturn) {
        return openBillService.openReturn(openReturn);
    }

    @ApiOperation("发票红冲")
    @PostMapping("/openRedInvoice")
    public CommonResult openRedInvoice(Principal principal,@RequestParam List<String> Ids) {
        return openBillService.openRedInvoice(principal,Ids);
    }

    @ApiOperation("开蓝票")
    @PostMapping("/openBlueInvoice")
    public CommonResult openBlueInvoice(Principal principal,@RequestParam List<String> Ids) {
        return openBillService.openBlueInvoice(principal,Ids);
    }



}
